package service

import (
	"custom-oracledb-exporter/collector"
	"custom-oracledb-exporter/config"
	"custom-oracledb-exporter/pkg"
	"log"
	"time"
)

var IntervalTime = config.C.Server.Interval

func init() {
	// 限制抓取时间不小于15s，对数据库有压力
	if config.C.Server.Interval <= 15 {
		IntervalTime = 15
	}
}

func ExposeMetrics() {
	// ticker 定期抓取指标
	ticker := time.NewTicker(time.Second * time.Duration(IntervalTime))
	go func() {
		for range ticker.C {
			collector.PasswdExpiredMetrics(pkg.DB)
			log.Println("Ticker Collect PasswdExpiredMetrics")
		}
	}()
}
